/**
 * 
 */
package at.ac.tuwien.ifs.qse.se1.web.controller;

import org.apache.log4j.Logger;
import at.ac.tuwien.ifs.qse.se1.bo.Student;
import at.ac.tuwien.ifs.qse.se1.dao.IStudentDAO;

/**
 * The Student controller delegates most of the work, to the underlying service layer. In our case
 * the service layer only consists of a set of DAOs.
 * @author Demolsky Markus
 */
public class StudentController {
    // Declaration
    private static Logger log = Logger.getLogger("qse.se1.web.controller");
    private IStudentDAO studentDao;
    private JsfBeanManager beanManager;

    /*
     * Dependency Injections
     */
    public void setStudentDao(IStudentDAO dao) {
        this.studentDao = dao;
    }

    public String updateStudent() {
        // Receive student from context
        Student student = (Student) beanManager.getBean("student");
        log.info("Update student " + student.getFirstName() + " " + student.getLastName());
        if(studentDao.updateStudent(student)!=null){
            return "success";   
        }else{
            return "failure";
        }
    }
}
